﻿Imports System.Net.Mail
Imports System.IO

Public Class Email
    Public Shared Sub EnviarEmail(sTo As String, sBody As String)
        Try
            'NOTE: Para que este método funcione, se requiere tener registrada MSMAPI32.OCX

            'Busca parámetros
            Dim _param As New StartFrame.BR.Utilitarios.Parametros
            Const param_smtp As String = "MAILS_SMTP"
            Const param_from As String = "MAILS_FROM"
            Const param_pwd As String = "MAILS_PWD"

            Dim smtpName As String
            Dim mail_from As String
            Dim mail_pwd As String
            smtpName = CType(_param.getParametro(param_smtp), String)
            mail_from = CType(_param.getParametro(param_from), String)
            mail_pwd = CType(_param.getParametro(param_pwd), String)

            'Arma el mail
            Dim Message As System.Net.Mail.MailMessage
            mail_from = mail_from.Replace(";", ",") 'reemplaza el separador de direcciones de mail ";" por ","
            sTo = sTo.Replace(";", ",")   'reemplaza el separador de direcciones de mail ";" por ","
            Message = New System.Net.Mail.MailMessage(mail_from, sTo, "Notificaciones GDP", sBody)

            'Envía el mail
            Dim smtp As New System.Net.Mail.SmtpClient(smtpName)
            smtp.Send(Message)

        Catch ex As Exception
            Throw ex
        End Try

    End Sub
End Class
